package com.linyf.design.factoryMethod.singleton;

import com.linyf.design.factoryMethod.impl.Product;
import com.linyf.design.factoryMethod.impl.YellowProduct;

import java.lang.reflect.Constructor;

/**
 * @Author: linyf
 * @Description: TODO
 * @DateTime: 2023/3/27 14:20
 **/
public class SimpleYellowProductFactory {

    private static YellowProduct product;

    static {
        try {
            final Class<?> aClass = Class.forName(YellowProduct.class.getName());
            final Constructor<?> declaredConstructor = aClass.getDeclaredConstructor();
            declaredConstructor.setAccessible(true);
            product = (YellowProduct) declaredConstructor.newInstance();
        } catch (Exception e) {

            e.printStackTrace();
        }
    }


    public static Product getSingleProduct(){
        return product;
    }

}
